package cn.waxcc.controller;

import cn.waxcc.config.MsmConstantUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: springboot-medicalapp
 * @ClassName MsmControlller
 * @description:
 * @author: JYF
 * @create: 2023-04-17 22:37
 * @Version 1.0
 */
@Controller
@CrossOrigin(origins = "*")
@RequestMapping("/msm")
public class MsmControlller {

    String s = null;

    @RequestMapping("/send")
    @ResponseBody
    public String test(String phone){
        s = MsmConstantUtils.generateValidateCode(6);
        System.out.println(s);
        MsmConstantUtils.sendPhone(s,phone);
        return "success";
    }

    @PostMapping("/authCodeLogin")
    public String authCodeLogin(String authCode) {
        System.out.println(authCode);
        if (authCode.equals(s)) {
            return "验证码成功！";
        }
        return "验证码失败！";
    }
}
